package com.xishu.entity.hardware;

import com.xishu.annotation.dao.DefaultValue;
import com.xishu.annotation.dao.FieldMapping;
import com.xishu.annotation.oplog.OplogAnnotation;
import com.xishu.annotation.valid.UniqueName;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.ShopItem;
import com.xishu.entity.oplog.OpName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

@Entity(name = "printer")
@Table(indexes = {@Index(columnList = "shopId")})
@Data
public class Printer extends ShopItem implements OpName {
    @Transient
    private String opName;

    @ApiModelProperty(value = "品牌")
    @OplogAnnotation(fieldName = "品牌")
    private String brand;

    @ApiModelProperty(value = "归属的餐厅公司")
    @OplogAnnotation(fieldName = "归属的餐厅公司")
    private Long companyId;

    @ApiModelProperty(value = "归属的分店")
    private Long shopId;

    @ApiModelProperty(value = "名称")
    @OplogAnnotation(fieldName = "名称")
    private String name;

    @ApiModelProperty(value = "设备序列号")
//    @UniqueName
    @OplogAnnotation(fieldName = "设备序列号")
    private String printerSn;

    @ApiModelProperty(value = "设备密钥")
    @OplogAnnotation(fieldName = "设备密钥")
    private String printerKey;

    @ApiModelProperty(value = "位置,厨房(kitchen)，吧台(barCounter)")
    @OplogAnnotation(fieldName = "位置")
    private String location;

    @ApiModelProperty(value = "输入其它时，显示的字符")
    @OplogAnnotation(fieldName = "其它")
    private String locationInput;

    private String title;

    @ApiModelProperty(value = "打印机的状态，1是在线，工作状态正常，2是在线，工作状态不正常(一般是没有纸了)，3是离线")
    @OplogAnnotation(fieldName = "打印机的状态")
    private Integer status;

    @ApiModelProperty(value = "打印标签列表")
    @Transient
    @FieldMapping(desField = "printerLabelJson", serialize = true)
    private List<String> printerLabelList;

    @ApiModelProperty(value = "打印标签列表")
    @FieldMapping(desField = "printerLabelList", serialize = false, genericType = "java.lang.String")
    private String printerLabelJson;

    @ApiModelProperty(value = "一菜一单模式")
    private Boolean oneItemOneOrder;

    @ApiModelProperty(value = "Same Order One Ticket")
    @DefaultValue(defaultValue = "false")
    private Boolean sameItemOneTicket;

    @ApiModelProperty(value = "语言，zh是中文，en是英文")
    private String lang;

    @ApiModelProperty(value = "备份打印机的id")
    private Long backPrinterId;

    @ApiModelProperty(value = "可以打印C端的订单")
    private Boolean printOrderInC;

    @ApiModelProperty(value = "打包单的打印机")
    private Boolean packing;

    @ApiModelProperty(value = "是否要打印C端下单成功的小票")
    private Boolean printPayedOrder;

    @DefaultValue(defaultValue = "false")
    private Boolean online;

    @Transient
    @ApiModelProperty(value = "场景归属的分店")
    private String shopName_zh;

    @Transient
    @ApiModelProperty(value = "场景归属的分店")
    private String shopName_en;

    @Override
    public String getOpName() {
        return opName;
    }

    @Override
    public String opType() {
        return "打印机";
    }

    @Override
    public String[] fieldName() {
        return new String[]{"shopId", "name"};
    }

}
